import http from '../utils/http'

// 请求轮播图数据的接口
// http 是对axios进行了完善 本质上还是axios
const getBanners = async () => {
    let data = await http.get('/small4/banner/list')
    // console.log(data);
    return data
}

// 请求砍价列表数据
const barginList = async () => {
    let data = await http.get('/small4/shop/goods/kanjia/list')
    return data
}

// 请求精选专题的数据
const getNews = async() => {
    let data = await http.get('/small4/cms/news/list')
    return data
}

// 请求人气推荐列表数据的接口
const recomend = async () => {
    return await http.get('/small4/shop/goods/list')
    // return data
}

// 请求商品详情数据
const detail = async (id) => {
    return await http.post('/small4/shop/goods/detail?id=' + id)
}

// 获取商品评价信息的接口
const reputations = async (id) => {
    return await http.post('/small4/shop/goods/reputation?goodsId=' + id)
}

// 获取省份的数据
const getProvinces = async () => {
    return await http.post('/common/region/province')
}

// 获取下级数据的接口
const getChildArea = async (id) => {
    return await http.post('/common/region/child?pid=' + id)
}


/**
 * 用户登录的接口
 * @params mobile是登录时输入的手机号码
 * @params pwd是用户输入的密码
 **/ 
const login = async(mobile, pwd) => {
    return await http.post('/small4/user/m/login?deviceId=007&deviceName=monkey&mobile=' + mobile + '&pwd=' + pwd)
}
export {
    getBanners,
    barginList,
    getNews,
    recomend,
    detail,
    reputations,
    getProvinces,
    getChildArea,
    login
}